﻿using System;
using CoreRay;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CoreRay.Testing
{
    /// <summary>
    /// This is a test class for BoundingBoxTest and is intended
    /// to contain all BoundingBoxTest Unit Tests
    /// </summary>
    [TestClass]
    public class BoundingBoxTest
    {
        /// <summary>
        /// A test for Intersect with Good result.
        /// </summary>
        [TestMethod]
        public void IntersectGoodTest()
        {
            // Setup
            BoundingBox target = new BoundingBox(new Vector3(-1, -1, -1), new Vector3(1, 1, 1));
            Ray ray = new Ray(new Vector3(0.0f, 0.0f, -2.0f), new Vector3(0.0f, 0.0f, 1.0f), 1.0f, 1000.0f);

            // Execute
            bool result = target.Intersect(ray);

            // Verify
            Assert.IsTrue(result);
        }

        /// <summary>
        /// A test for Intersect with wrong result.
        /// </summary>
        [TestMethod]
        public void IntersectWrongTest()
        {
            // Setup
            BoundingBox target = new BoundingBox(new Vector3(-1, -1, -1), new Vector3(1, 1, 1));
            Ray ray = new Ray(new Vector3(1.2f, 0.0f, -2.0f), new Vector3(0.0f, 0.0f, 1.0f), 1.0f, 1000.0f);

            // Execute
            bool result = target.Intersect(ray);

            // Verify
            Assert.IsFalse(result);
        }

        /// <summary>
        /// A test for Intersect with wrong result.
        /// </summary>
        [TestMethod]
        public void IntersectWrong2Test()
        {
            // Setup
            BoundingBox target = new BoundingBox(new Vector3(-1, -1, -1), new Vector3(1, 1, 1));
            Ray ray = new Ray(new Vector3(-1.2f, 0.0f, -2.0f), new Vector3(0.0f, 0.0f, 1.0f), 1.0f, 1000.0f);

            // Execute
            bool result = target.Intersect(ray);

            // Verify
            Assert.IsFalse(result);
        }

        /// <summary>
        /// A test for Intersect with wrong result.
        /// </summary>
        [TestMethod]
        public void IntersectWrong3Test()
        {
            // Setup
            BoundingBox target = new BoundingBox(new Vector3(-2.2f, -1.0f, -1.0f), new Vector3(-0.2f, 1.0f, 1.0f));
            Ray ray = new Ray(new Vector3(-0.45f, 0.34f, -6.0f), new Vector3(-0.39f, 0.29f, 0.86f), 1.0f, 1000.0f);

            // Execute
            bool result = target.Intersect(ray);

            // Verify
            Assert.IsFalse(result);
        }
    }
}
